/*
 *
 * Copyright (c) 2007, Sun Microsystems, Inc.
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *  * Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *  * Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *  * Neither the name of Sun Microsystems nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
// This class was generated by 172 StubGenerator.
// Contents subject to change without notice.
// @generated
package uns.fit.gis.serverscript;

import javax.microedition.xml.rpc.ComplexType;
import javax.microedition.xml.rpc.Element;
import javax.microedition.xml.rpc.Operation;
import javax.microedition.xml.rpc.Type;

import javax.xml.namespace.QName;
import javax.xml.rpc.JAXRPCException;


public class Interface_Stub implements Interface, javax.xml.rpc.Stub {
    // 
    //  End user methods
    // 
    protected static final QName _qname_String_1 = new QName("", "String_1");
    protected static final QName _qname_String_2 = new QName("", "String_2");
    protected static final QName _qname_result = new QName("", "result");
    protected static final QName _qname_request =
        new QName("http://serverscript.org/types", "request");
    protected static final QName _qname_requestResponse =
        new QName("http://serverscript.org/types", "requestResponse");
    protected static final QName _qname_wsdl_request =
        new QName("http://serverscript.org/wsdl", "request");
    protected static final Element _type_request;
    protected static final Element _type_requestResponse;

    static {
        // Create all of the Type's that this stub uses, once.
        Element _type_String_1;
        _type_String_1 = new Element(_qname_String_1, Type.STRING, 1, 1, true);

        Element _type_String_2;
        _type_String_2 = new Element(_qname_String_2, Type.STRING, 1, 1, true);

        ComplexType _complexType_request;
        _complexType_request = new ComplexType();
        _complexType_request.elements = new Element[2];
        _complexType_request.elements[0] = _type_String_1;
        _complexType_request.elements[1] = _type_String_2;
        _type_request = new Element(_qname_request, _complexType_request);

        Element _type_result;
        _type_result = new Element(_qname_result, Type.STRING, 1, 1, true);

        ComplexType _complexType_requestResponse;
        _complexType_requestResponse = new ComplexType();
        _complexType_requestResponse.elements = new Element[1];
        _complexType_requestResponse.elements[0] = _type_result;
        _type_requestResponse = new Element(_qname_requestResponse, _complexType_requestResponse);
    }

    private String[] _propertyNames;
    private Object[] _propertyValues;

    public Interface_Stub() {
        _propertyNames = new String[] { ENDPOINT_ADDRESS_PROPERTY };
        _propertyValues = new Object[] { "http://cds.cmsg.sun.com:80/serverscript/serverscript" };
    }

    public void _setProperty(String name, Object value) {
        int size = _propertyNames.length;

        for (int i = 0; i < size; ++i) {
            if (_propertyNames[i].equals(name)) {
                _propertyValues[i] = value;

                return;
            }
        }

        // Need to expand our array for a new property
        String[] newPropNames = new String[size + 1];
        System.arraycopy(_propertyNames, 0, newPropNames, 0, size);
        _propertyNames = newPropNames;

        Object[] newPropValues = new Object[size + 1];
        System.arraycopy(_propertyValues, 0, newPropValues, 0, size);
        _propertyValues = newPropValues;
        _propertyNames[size] = name;
        _propertyValues[size] = value;
    }

    public Object _getProperty(String name) {
        for (int i = 0; i < _propertyNames.length; ++i) {
            if (_propertyNames[i].equals(name)) {
                return _propertyValues[i];
            }
        }

        if (ENDPOINT_ADDRESS_PROPERTY.equals(name) || USERNAME_PROPERTY.equals(name) ||
                PASSWORD_PROPERTY.equals(name)) {
            return null;
        }

        if (SESSION_MAINTAIN_PROPERTY.equals(name)) {
            return new java.lang.Boolean(false);
        }

        throw new JAXRPCException("Stub does not recognize property: " + name);
    }

    protected void _prepOperation(Operation op) {
        for (int i = 0; i < _propertyNames.length; ++i) {
            op.setProperty(_propertyNames[i], _propertyValues[i].toString());
        }
    }

    // 
    //  Begin user methods
    // 
    public java.lang.String request(java.lang.String string_1, java.lang.String string_2)
        throws java.rmi.RemoteException {
        // Copy the incoming values into an Object array if needed.
        Object[] inputObject = new Object[2];
        inputObject[0] = string_1;
        inputObject[1] = string_2;

        Operation op =
            Operation.newInstance(_qname_wsdl_request, _type_request, _type_requestResponse);
        _prepOperation(op);
        op.setProperty(Operation.SOAPACTION_URI_PROPERTY, "");

        Object resultObj;

        try {
            resultObj = op.invoke(inputObject);
        } catch (JAXRPCException e) {
            Throwable cause = e.getLinkedCause();

            if (cause instanceof java.rmi.RemoteException) {
                throw (java.rmi.RemoteException)cause;
            }

            throw e;
        }

        java.lang.String result;

        // Convert the result into the right Java type.
        // Unwrapped return value
        Object resultObj2 = ((Object[])resultObj)[0];
        result = (java.lang.String)resultObj2;

        return result;
    }
}
